//
//  HLWalletRequest.m
//  YueYue
//
//  Created by hulu001 on 2023/6/15.
//

#import "HLWalletRequest.h"

@implementation HLWalletRequest
{
    NSDictionary *_params;
    HLWalletType _type;
}

- (id)initWithType:(HLWalletType)type params:(NSDictionary *)params
{
    self = [super init];
    
    if (self) {
        _type = type;
        _params = params;
    }
    
    return self;
}



- (NSString *)requestUrl
{
    switch (_type) {
        case HLWalletTypeBalance:
            return @"/wallet/user_coin_balance";
            break;
        case HLWalletTypeUser:
            return @"/wallet/user_wallet";
            break;
    }
    
}

- (YTKRequestMethod)requestMethod
{
    return YTKRequestMethodGET;
}

- (id)requestArgument
{
    if (_params){
        return _params;
    } else {
        return @{};
    }
}

- (NSString *)balance
{
    NSString *data = [self.result valueForKey:@"data"];
    return data;
}

- (HLWalletModel *)wallet
{
    HLWalletModel *wallet;
    
    NSDictionary *data = [self.result valueForKey:@"data"];
    if (![data isKindOfClass:[NSDictionary class]]){
        return wallet;
    }
    wallet = [HLWalletModel mj_objectWithKeyValues:data];
    
    return wallet;
}

@end
